package home.project.misc;

import openfl.geom.Point;
import openfl.geom.Rectangle;
import openfl.display.BitmapData;
import openfl.Assets;
/**
 * ...
 * @author an.vuongngocduy
 */
class Image {
	public var source(default, null):String;
	public var width(default, null):Int;
	public var height(default, null):Int;
	public var transparentColor(default, null):Null<Int>;
	
	public function new(p_src:String, ?p_transColor:Int = null) {
		var bm:BitmapData = Assets.getBitmapData("img/" + p_src);	
		source = p_src;
		transparentColor = p_transColor;
		width = bm.width;
		height = bm.height;
	}
	
	public function getBitmapData():BitmapData {
		var original:BitmapData = Assets.getBitmapData("img/" + source);
		var res:UInt = original.threshold(original, 
				new Rectangle(0, 0, original.width, original.height), new Point(0, 0), 
				"==", transparentColor, 0, 0xFFFFFFFF, true);
		return original;
	}
}